//
//  LZRestaurantAuthOpenTimeSelectCell.m
//  laziz_Merchant
//
//  Created by xbnzd on 17/3/3.
//  Copyright © 2017年 XBN. All rights reserved.
//

#import "LZRestaurantAuthOpenTimeSelectCell.h"
#import "UIView+Rotation.h"

@interface LZRestaurantAuthOpenTimeSelectCell()
@property (weak, nonatomic) IBOutlet UILabel *cellNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *beginTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *midLabel;
@property (weak, nonatomic) IBOutlet UILabel *endTimeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *arrowImg;

@end

@implementation LZRestaurantAuthOpenTimeSelectCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.arrowImg setLanguageRotaion];
    self.cellNameLabel.text = LZLocalizedString(@"open_time", nil);
    UITapGestureRecognizer *beginTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickBeginTimeLabel)];
    self.beginTimeLabel.userInteractionEnabled = YES;
    [self.beginTimeLabel addGestureRecognizer:beginTap];
    
    UITapGestureRecognizer *endTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickEndTimeLabel)];
    self.endTimeLabel.userInteractionEnabled = YES;
    [self.endTimeLabel addGestureRecognizer:endTap];
}

#pragma mark -
#pragma mark load data
- (void)loadBeginTime:(NSString *)begintTimeStr andEndTime:(NSString *)endTime
{
    if (begintTimeStr.length == 0) {
        self.beginTimeLabel.text = LZLocalizedString(@"from_time", nil);
        self.beginTimeLabel.textColor = UIColorFromRGB(0xcccccc, 1);
    }else{
        self.beginTimeLabel.text = begintTimeStr;
        self.beginTimeLabel.textColor = UIColorFromRGB(0x333333, 1);
        self.midLabel.textColor = UIColorFromRGB(0x333333, 1);
    }
    
    if (endTime.length == 0) {
        self.endTimeLabel.text = LZLocalizedString(@"to_time", nil);
        self.endTimeLabel.textColor = UIColorFromRGB(0xcccccc, 1);
    }else{
        self.endTimeLabel.text = endTime;
        self.endTimeLabel.textColor = UIColorFromRGB(0x333333, 1);
        self.midLabel.textColor = UIColorFromRGB(0x333333, 1);
    }
}

#pragma mark -
#pragma mark method

/**
 是否允许编辑

 @param enable <#enable description#>
 */
- (void)changeCellEnabled:(BOOL)enable
{
    self.beginTimeLabel.userInteractionEnabled = enable;
    self.endTimeLabel.userInteractionEnabled = enable;
}

#pragma mark -
#pragma mark event
- (void)clickBeginTimeLabel
{
    if (self.restaurantAuthOpenTimeCellDelegate && [self.restaurantAuthOpenTimeCellDelegate respondsToSelector:@selector(clickTimeLabelAndIsBeginTime:)]) {
        [self.restaurantAuthOpenTimeCellDelegate clickTimeLabelAndIsBeginTime:YES];
    }
}

- (void)clickEndTimeLabel
{
    if (self.restaurantAuthOpenTimeCellDelegate && [self.restaurantAuthOpenTimeCellDelegate respondsToSelector:@selector(clickTimeLabelAndIsBeginTime:)]) {
        [self.restaurantAuthOpenTimeCellDelegate clickTimeLabelAndIsBeginTime:NO];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
